<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1" />
<meta name="generator" content="pdoc 0.9.2" />
<title>graia.broadcast.interfaces.dispatcher API documentation</title>
<meta name="description" content="" />
<link rel="preload stylesheet" as="style" href="https://cdnjs.cloudflare.com/ajax/libs/10up-sanitize.css/11.0.1/sanitize.min.css" integrity="sha256-PK9q560IAAa6WVRRh76LtCaI8pjTJ2z11v0miyNNjrs=" crossorigin>
<link rel="preload stylesheet" as="style" href="https://cdnjs.cloudflare.com/ajax/libs/10up-sanitize.css/11.0.1/typography.min.css" integrity="sha256-7l/o7C8jubJiy74VsKTidCy1yBkRtiUGbVkYBylBqUg=" crossorigin>
<link rel="stylesheet preload" as="style" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.1.1/styles/github.min.css" crossorigin>
<style>:root{--highlight-color:#fe9}.flex{display:flex !important}body{line-height:1.5em}#content{padding:20px}#sidebar{padding:30px;overflow:hidden}#sidebar > *:last-child{margin-bottom:2cm}.http-server-breadcrumbs{font-size:130%;margin:0 0 15px 0}#footer{font-size:.75em;padding:5px 30px;border-top:1px solid #ddd;text-align:right}#footer p{margin:0 0 0 1em;display:inline-block}#footer p:last-child{margin-right:30px}h1,h2,h3,h4,h5{font-weight:300}h1{font-size:2.5em;line-height:1.1em}h2{font-size:1.75em;margin:1em 0 .50em 0}h3{font-size:1.4em;margin:25px 0 10px 0}h4{margin:0;font-size:105%}h1:target,h2:target,h3:target,h4:target,h5:target,h6:target{background:var(--highlight-color);padding:.2em 0}a{color:#058;text-decoration:none;transition:color .3s ease-in-out}a:hover{color:#e82}.title code{font-weight:bold}h2[id^="header-"]{margin-top:2em}.ident{color:#900}pre code{background:#f8f8f8;font-size:.8em;line-height:1.4em}code{background:#f2f2f1;padding:1px 4px;overflow-wrap:break-word}h1 code{background:transparent}pre{background:#f8f8f8;border:0;border-top:1px solid #ccc;border-bottom:1px solid #ccc;margin:1em 0;padding:1ex}#http-server-module-list{display:flex;flex-flow:column}#http-server-module-list div{display:flex}#http-server-module-list dt{min-width:10%}#http-server-module-list p{margin-top:0}.toc ul,#index{list-style-type:none;margin:0;padding:0}#index code{background:transparent}#index h3{border-bottom:1px solid #ddd}#index ul{padding:0}#index h4{margin-top:.6em;font-weight:bold}@media (min-width:200ex){#index .two-column{column-count:2}}@media (min-width:300ex){#index .two-column{column-count:3}}dl{margin-bottom:2em}dl dl:last-child{margin-bottom:4em}dd{margin:0 0 1em 3em}#header-classes + dl > dd{margin-bottom:3em}dd dd{margin-left:2em}dd p{margin:10px 0}.name{background:#eee;font-weight:bold;font-size:.85em;padding:5px 10px;display:inline-block;min-width:40%}.name:hover{background:#e0e0e0}dt:target .name{background:var(--highlight-color)}.name > span:first-child{white-space:nowrap}.name.class > span:nth-child(2){margin-left:.4em}.inherited{color:#999;border-left:5px solid #eee;padding-left:1em}.inheritance em{font-style:normal;font-weight:bold}.desc h2{font-weight:400;font-size:1.25em}.desc h3{font-size:1em}.desc dt code{background:inherit}.source summary,.git-link-div{color:#666;text-align:right;font-weight:400;font-size:.8em;text-transform:uppercase}.source summary > *{white-space:nowrap;cursor:pointer}.git-link{color:inherit;margin-left:1em}.source pre{max-height:500px;overflow:auto;margin:0}.source pre code{font-size:12px;overflow:visible}.hlist{list-style:none}.hlist li{display:inline}.hlist li:after{content:',\2002'}.hlist li:last-child:after{content:none}.hlist .hlist{display:inline;padding-left:1em}img{max-width:100%}td{padding:0 .5em}.admonition{padding:.1em .5em;margin-bottom:1em}.admonition-title{font-weight:bold}.admonition.note,.admonition.info,.admonition.important{background:#aef}.admonition.todo,.admonition.versionadded,.admonition.tip,.admonition.hint{background:#dfd}.admonition.warning,.admonition.versionchanged,.admonition.deprecated{background:#fd4}.admonition.error,.admonition.danger,.admonition.caution{background:lightpink}</style>
<style media="screen and (min-width: 700px)">@media screen and (min-width:700px){#sidebar{width:30%;height:100vh;overflow:auto;position:sticky;top:0}#content{width:70%;max-width:100ch;padding:3em 4em;border-left:1px solid #ddd}pre code{font-size:1em}.item .name{font-size:1em}main{display:flex;flex-direction:row-reverse;justify-content:flex-end}.toc ul ul,#index ul{padding-left:1.5em}.toc > ul > li{margin-top:.5em}}</style>
<style media="print">@media print{#sidebar h1{page-break-before:always}.source{display:none}}@media print{*{background:transparent !important;color:#000 !important;box-shadow:none !important;text-shadow:none !important}a[href]:after{content:" (" attr(href) ")";font-size:90%}a[href][title]:after{content:none}abbr[title]:after{content:" (" attr(title) ")"}.ir a:after,a[href^="javascript:"]:after,a[href^="#"]:after{content:""}pre,blockquote{border:1px solid #999;page-break-inside:avoid}thead{display:table-header-group}tr,img{page-break-inside:avoid}img{max-width:100% !important}@page{margin:0.5cm}p,h2,h3{orphans:3;widows:3}h1,h2,h3,h4,h5,h6{page-break-after:avoid}}</style>
<script defer src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.1.1/highlight.min.js" integrity="sha256-Uv3H6lx7dJmRfRvH8TH6kJD1TSK1aFcwgx+mdg3epi8=" crossorigin></script>
<script>window.addEventListener('DOMContentLoaded', () => hljs.initHighlighting())</script>
</head>
<body>
<main>
<article id="content">
<header>
<h1 class="title">Module <code>graia.broadcast.interfaces.dispatcher</code></h1>
</header>
<section id="section-intro">
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">from inspect import isclass, isfunction, ismethod
import itertools
from functools import lru_cache, partial

from typing import (
    Any,
    Dict,
    Generator,
    List,
    Optional,
    TYPE_CHECKING,
    Tuple,
)
from graia.broadcast.entities.dispatcher import BaseDispatcher
from graia.broadcast.entities.event import BaseEvent

from graia.broadcast.entities.context import ExecutionContext, ParameterContext
from graia.broadcast.entities.signatures import Force
from graia.broadcast.entities.track_log import TrackLog, TrackLogType
from graia.broadcast.exceptions import RequirementCrashed
from graia.broadcast.typing import T_Dispatcher, T_Dispatcher_Callable

from ..utilles import NestableIterable, run_always_await_safely, cached_getattr

if TYPE_CHECKING:
    from graia.broadcast import Broadcast


DEFAULT_LIFECYCLE_NAMES = (
    &#34;beforeDispatch&#34;,
    &#34;afterDispatch&#34;,
    &#34;beforeExecution&#34;,
    &#34;afterExecution&#34;,
    &#34;beforeTargetExec&#34;,
    &#34;afterTargetExec&#34;,
)


class EmptyEvent(BaseEvent):
    class Dispatcher(BaseDispatcher):
        @staticmethod
        def catch(_):
            pass


class DispatcherInterface:
    broadcast: &#34;Broadcast&#34;

    execution_contexts: List[&#34;ExecutionContext&#34;]
    parameter_contexts: List[&#34;ParameterContext&#34;]

    track_logs: List[TrackLog] = None

    @property
    def track_log(self):
        return self.track_logs[-1]

    @staticmethod
    @lru_cache(None)
    def get_lifecycle_refs(
        dispatcher: &#34;T_Dispatcher&#34;,
    ) -&gt; Optional[Dict[str, List]]:
        from graia.broadcast.entities.dispatcher import BaseDispatcher

        lifecycle_refs: Dict[str, List] = {}
        if not isinstance(dispatcher, (BaseDispatcher, type)):
            return

        for name in DEFAULT_LIFECYCLE_NAMES:
            lifecycle_refs.setdefault(name, [])
            abstract_lifecycle_func = cached_getattr(BaseDispatcher, name)
            unbound_attr = getattr(dispatcher, name, None)

            if unbound_attr is None:
                continue

            orig_call = unbound_attr
            while ismethod(orig_call):
                orig_call = unbound_attr.__func__

            if orig_call is abstract_lifecycle_func:
                continue

            lifecycle_refs[name].append(unbound_attr)

        return lifecycle_refs

    def dispatcher_pure_generator(self) -&gt; Generator[None, None, T_Dispatcher]:
        return itertools.chain(
            self.execution_contexts[0].dispatchers,
            self.parameter_contexts[-1].dispatchers,
            self.execution_contexts[-1].dispatchers,
        )

    def flush_lifecycle_refs(
        self,
        dispatchers: List[&#34;T_Dispatcher&#34;] = None,
    ):
        from graia.broadcast.entities.dispatcher import BaseDispatcher

        lifecycle_refs = self.execution_contexts[-1].lifecycle_refs
        if dispatchers is None and lifecycle_refs:  # 已经刷新.
            return

        for dispatcher in dispatchers or self.dispatcher_pure_generator():
            if (
                not isinstance(dispatcher, BaseDispatcher)
                or dispatcher.__class__ is type
            ):
                continue

            for name, value in self.get_lifecycle_refs(dispatcher).items():
                lifecycle_refs.setdefault(name, [])
                lifecycle_refs[name].extend(value)

    async def exec_lifecycle(self, lifecycle_name: str, *args, **kwargs):
        lifecycle_funcs = self.execution_contexts[-1].lifecycle_refs.get(
            lifecycle_name, []
        )
        if lifecycle_funcs:
            for func in lifecycle_funcs:
                await run_always_await_safely(func, self, *args, **kwargs)

    def inject_local_raw(self, *dispatchers: List[&#34;T_Dispatcher&#34;]):
        # 为什么没有 flush: 因为这里的 lifecycle 是无意义的.
        for dispatcher in dispatchers[::-1]:
            self.parameter_contexts[-1].dispatchers.insert(0, dispatcher)

    def inject_execution_raw(self, *dispatchers: List[&#34;T_Dispatcher&#34;]):
        for dispatcher in dispatchers:
            self.execution_contexts[-1].dispatchers.insert(0, dispatcher)

        self.flush_lifecycle_refs(dispatchers)

    def inject_global_raw(self, *dispatchers: List[&#34;T_Dispatcher&#34;]):
        # self.dispatchers.extend(dispatchers)
        for dispatcher in dispatchers[::-1]:
            self.execution_contexts[0].dispatchers.insert(1, dispatcher)

        self.flush_lifecycle_refs(dispatchers)

    @property
    def name(self) -&gt; str:
        return self.parameter_contexts[-1].name

    @property
    def annotation(self) -&gt; Any:
        return self.parameter_contexts[-1].annotation

    @property
    def default(self) -&gt; Any:
        return self.parameter_contexts[-1].default

    @property
    def _index(self) -&gt; int:
        return self.execution_contexts[-1]._index

    @property
    def event(self) -&gt; BaseEvent:
        return self.execution_contexts[-1].event

    @property
    def global_dispatcher(self) -&gt; List[T_Dispatcher]:
        return self.execution_contexts[0].dispatchers

    @property
    def current_path(self) -&gt; NestableIterable[int, T_Dispatcher]:
        return self.parameter_contexts[-1].path

    @property
    def has_current_exec_context(self) -&gt; bool:
        return len(self.execution_contexts) &gt;= 2

    @property
    def has_current_param_context(self) -&gt; bool:
        return len(self.parameter_contexts) &gt;= 2

    def __init__(self, broadcast_instance: &#34;Broadcast&#34;) -&gt; None:
        self.broadcast = broadcast_instance
        self.execution_contexts = [ExecutionContext([], EmptyEvent())]
        self.parameter_contexts = [
            ParameterContext(
                None,
                None,
                None,
                [],
                [
                    [],
                ],
            )
        ]
        self.track_logs = [TrackLog()]

    async def __aenter__(self) -&gt; &#34;DispatcherInterface&#34;:
        return self

    async def __aexit__(self, _, exc: Exception, tb):
        await self.exit_current_execution()
        if tb is not None:
            raise exc.with_traceback(tb)

    def start_execution(
        self,
        event: BaseEvent,
        dispatchers: List[T_Dispatcher],
        track_log_receiver: TrackLog = None,
    ) -&gt; &#34;DispatcherInterface&#34;:
        self.execution_contexts.append(ExecutionContext(dispatchers, event))
        self.flush_lifecycle_refs()
        self.track_logs.append(track_log_receiver or TrackLog())
        return self

    async def exit_current_execution(self):
        self.execution_contexts.pop()
        self.track_logs.pop()

    @staticmethod
    @lru_cache(None)
    def dispatcher_callable_detector(dispatcher: T_Dispatcher) -&gt; T_Dispatcher_Callable:
        if hasattr(dispatcher, &#34;catch&#34;):
            if isfunction(dispatcher.catch) or not isclass(dispatcher):
                return dispatcher.catch
            else:
                return partial(dispatcher.catch, None)
        elif callable(dispatcher):
            return dispatcher
        else:
            raise ValueError(&#34;invaild dispatcher: &#34;, dispatcher)

    def init_dispatch_path(self) -&gt; List[List[&#34;T_Dispatcher&#34;]]:
        return [
            [],
            self.execution_contexts[0].dispatchers,
            self.parameter_contexts[-1].dispatchers,
            self.execution_contexts[-1].dispatchers,
        ]

    async def lookup_param_without_log(
        self,
        name: str,
        annotation: Any,
        default: Any,
        using_path: List[List[&#34;T_Dispatcher&#34;]] = None,
    ) -&gt; Any:
        self.parameter_contexts.append(
            ParameterContext(
                name, annotation, default, [], using_path or self.init_dispatch_path()
            )
        )

        result = None
        try:
            for dispatcher in self.current_path:
                result = await run_always_await_safely(
                    self.dispatcher_callable_detector(dispatcher), self
                )

                if result is None:
                    continue

                if result.__class__ is Force:
                    result = result.target

                self.execution_contexts[-1]._index = 0
                return result
            else:
                raise RequirementCrashed(
                    &#34;the dispatching requirement crashed: &#34;,
                    self.name,
                    self.annotation,
                    self.default,
                )
        finally:
            self.parameter_contexts.pop()

    async def lookup_param(
        self,
        name: str,
        annotation: Any,
        default: Any,
        using_path: List[List[&#34;T_Dispatcher&#34;]] = None,
    ) -&gt; Any:
        self.parameter_contexts.append(
            ParameterContext(
                name, annotation, default, [], using_path or self.init_dispatch_path()
            )
        )
        track_log = self.track_log.log

        track_log.append((TrackLogType.LookupStart, name, annotation, default))
        try:
            for dispatcher in self.current_path:
                result = await run_always_await_safely(
                    self.dispatcher_callable_detector(dispatcher), self
                )

                if result is None:
                    self.track_log.fluent_success = False
                    track_log.append((TrackLogType.Continue, name, dispatcher))
                    continue

                if result.__class__ is Force:
                    result = result.target

                track_log.append((TrackLogType.Result, name, dispatcher))
                self.execution_contexts[-1]._index = 0
                return result
            else:
                track_log.append((TrackLogType.RequirementCrashed, name))
                raise RequirementCrashed(
                    &#34;the dispatching requirement crashed: &#34;,
                    self.name,
                    self.annotation,
                    self.default,
                )
        finally:
            track_log.append((TrackLogType.LookupEnd, name))
            self.parameter_contexts.pop()

    async def lookup_using_current(self) -&gt; Any:
        result = None
        for dispatcher in self.current_path:
            result = await run_always_await_safely(
                self.dispatcher_callable_detector(dispatcher), self
            )
            if result is None:
                continue

            if result.__class__ is Force:
                result = result.target

            self.execution_contexts[-1]._index = 0
            return result
        else:
            raise RequirementCrashed(
                &#34;the dispatching requirement crashed: &#34;,
                self.name,
                self.annotation,
                self.default,
            )

    async def lookup_by_directly(
        self,
        dispatcher: T_Dispatcher,
        name: str,
        annotation: Any,
        default: Any,
        using_path: List[List[&#34;T_Dispatcher&#34;]] = None,
    ) -&gt; Any:
        self.parameter_contexts.append(
            ParameterContext(
                name, annotation, default, [], using_path or self.init_dispatch_path()
            )
        )

        dispatcher_callable = self.dispatcher_callable_detector(dispatcher)

        try:
            result = await run_always_await_safely(dispatcher_callable, self)
            if result.__class__ is Force:
                return result.target

            return result
        finally:
            self.parameter_contexts.pop()</code></pre>
</details>
</section>
<section>
</section>
<section>
</section>
<section>
</section>
<section>
<h2 class="section-title" id="header-classes">Classes</h2>
<dl>
<dt id="graia.broadcast.interfaces.dispatcher.DispatcherInterface"><code class="flex name class">
<span>class <span class="ident">DispatcherInterface</span></span>
<span>(</span><span>broadcast_instance: Broadcast)</span>
</code></dt>
<dd>
<div class="desc"></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">class DispatcherInterface:
    broadcast: &#34;Broadcast&#34;

    execution_contexts: List[&#34;ExecutionContext&#34;]
    parameter_contexts: List[&#34;ParameterContext&#34;]

    track_logs: List[TrackLog] = None

    @property
    def track_log(self):
        return self.track_logs[-1]

    @staticmethod
    @lru_cache(None)
    def get_lifecycle_refs(
        dispatcher: &#34;T_Dispatcher&#34;,
    ) -&gt; Optional[Dict[str, List]]:
        from graia.broadcast.entities.dispatcher import BaseDispatcher

        lifecycle_refs: Dict[str, List] = {}
        if not isinstance(dispatcher, (BaseDispatcher, type)):
            return

        for name in DEFAULT_LIFECYCLE_NAMES:
            lifecycle_refs.setdefault(name, [])
            abstract_lifecycle_func = cached_getattr(BaseDispatcher, name)
            unbound_attr = getattr(dispatcher, name, None)

            if unbound_attr is None:
                continue

            orig_call = unbound_attr
            while ismethod(orig_call):
                orig_call = unbound_attr.__func__

            if orig_call is abstract_lifecycle_func:
                continue

            lifecycle_refs[name].append(unbound_attr)

        return lifecycle_refs

    def dispatcher_pure_generator(self) -&gt; Generator[None, None, T_Dispatcher]:
        return itertools.chain(
            self.execution_contexts[0].dispatchers,
            self.parameter_contexts[-1].dispatchers,
            self.execution_contexts[-1].dispatchers,
        )

    def flush_lifecycle_refs(
        self,
        dispatchers: List[&#34;T_Dispatcher&#34;] = None,
    ):
        from graia.broadcast.entities.dispatcher import BaseDispatcher

        lifecycle_refs = self.execution_contexts[-1].lifecycle_refs
        if dispatchers is None and lifecycle_refs:  # 已经刷新.
            return

        for dispatcher in dispatchers or self.dispatcher_pure_generator():
            if (
                not isinstance(dispatcher, BaseDispatcher)
                or dispatcher.__class__ is type
            ):
                continue

            for name, value in self.get_lifecycle_refs(dispatcher).items():
                lifecycle_refs.setdefault(name, [])
                lifecycle_refs[name].extend(value)

    async def exec_lifecycle(self, lifecycle_name: str, *args, **kwargs):
        lifecycle_funcs = self.execution_contexts[-1].lifecycle_refs.get(
            lifecycle_name, []
        )
        if lifecycle_funcs:
            for func in lifecycle_funcs:
                await run_always_await_safely(func, self, *args, **kwargs)

    def inject_local_raw(self, *dispatchers: List[&#34;T_Dispatcher&#34;]):
        # 为什么没有 flush: 因为这里的 lifecycle 是无意义的.
        for dispatcher in dispatchers[::-1]:
            self.parameter_contexts[-1].dispatchers.insert(0, dispatcher)

    def inject_execution_raw(self, *dispatchers: List[&#34;T_Dispatcher&#34;]):
        for dispatcher in dispatchers:
            self.execution_contexts[-1].dispatchers.insert(0, dispatcher)

        self.flush_lifecycle_refs(dispatchers)

    def inject_global_raw(self, *dispatchers: List[&#34;T_Dispatcher&#34;]):
        # self.dispatchers.extend(dispatchers)
        for dispatcher in dispatchers[::-1]:
            self.execution_contexts[0].dispatchers.insert(1, dispatcher)

        self.flush_lifecycle_refs(dispatchers)

    @property
    def name(self) -&gt; str:
        return self.parameter_contexts[-1].name

    @property
    def annotation(self) -&gt; Any:
        return self.parameter_contexts[-1].annotation

    @property
    def default(self) -&gt; Any:
        return self.parameter_contexts[-1].default

    @property
    def _index(self) -&gt; int:
        return self.execution_contexts[-1]._index

    @property
    def event(self) -&gt; BaseEvent:
        return self.execution_contexts[-1].event

    @property
    def global_dispatcher(self) -&gt; List[T_Dispatcher]:
        return self.execution_contexts[0].dispatchers

    @property
    def current_path(self) -&gt; NestableIterable[int, T_Dispatcher]:
        return self.parameter_contexts[-1].path

    @property
    def has_current_exec_context(self) -&gt; bool:
        return len(self.execution_contexts) &gt;= 2

    @property
    def has_current_param_context(self) -&gt; bool:
        return len(self.parameter_contexts) &gt;= 2

    def __init__(self, broadcast_instance: &#34;Broadcast&#34;) -&gt; None:
        self.broadcast = broadcast_instance
        self.execution_contexts = [ExecutionContext([], EmptyEvent())]
        self.parameter_contexts = [
            ParameterContext(
                None,
                None,
                None,
                [],
                [
                    [],
                ],
            )
        ]
        self.track_logs = [TrackLog()]

    async def __aenter__(self) -&gt; &#34;DispatcherInterface&#34;:
        return self

    async def __aexit__(self, _, exc: Exception, tb):
        await self.exit_current_execution()
        if tb is not None:
            raise exc.with_traceback(tb)

    def start_execution(
        self,
        event: BaseEvent,
        dispatchers: List[T_Dispatcher],
        track_log_receiver: TrackLog = None,
    ) -&gt; &#34;DispatcherInterface&#34;:
        self.execution_contexts.append(ExecutionContext(dispatchers, event))
        self.flush_lifecycle_refs()
        self.track_logs.append(track_log_receiver or TrackLog())
        return self

    async def exit_current_execution(self):
        self.execution_contexts.pop()
        self.track_logs.pop()

    @staticmethod
    @lru_cache(None)
    def dispatcher_callable_detector(dispatcher: T_Dispatcher) -&gt; T_Dispatcher_Callable:
        if hasattr(dispatcher, &#34;catch&#34;):
            if isfunction(dispatcher.catch) or not isclass(dispatcher):
                return dispatcher.catch
            else:
                return partial(dispatcher.catch, None)
        elif callable(dispatcher):
            return dispatcher
        else:
            raise ValueError(&#34;invaild dispatcher: &#34;, dispatcher)

    def init_dispatch_path(self) -&gt; List[List[&#34;T_Dispatcher&#34;]]:
        return [
            [],
            self.execution_contexts[0].dispatchers,
            self.parameter_contexts[-1].dispatchers,
            self.execution_contexts[-1].dispatchers,
        ]

    async def lookup_param_without_log(
        self,
        name: str,
        annotation: Any,
        default: Any,
        using_path: List[List[&#34;T_Dispatcher&#34;]] = None,
    ) -&gt; Any:
        self.parameter_contexts.append(
            ParameterContext(
                name, annotation, default, [], using_path or self.init_dispatch_path()
            )
        )

        result = None
        try:
            for dispatcher in self.current_path:
                result = await run_always_await_safely(
                    self.dispatcher_callable_detector(dispatcher), self
                )

                if result is None:
                    continue

                if result.__class__ is Force:
                    result = result.target

                self.execution_contexts[-1]._index = 0
                return result
            else:
                raise RequirementCrashed(
                    &#34;the dispatching requirement crashed: &#34;,
                    self.name,
                    self.annotation,
                    self.default,
                )
        finally:
            self.parameter_contexts.pop()

    async def lookup_param(
        self,
        name: str,
        annotation: Any,
        default: Any,
        using_path: List[List[&#34;T_Dispatcher&#34;]] = None,
    ) -&gt; Any:
        self.parameter_contexts.append(
            ParameterContext(
                name, annotation, default, [], using_path or self.init_dispatch_path()
            )
        )
        track_log = self.track_log.log

        track_log.append((TrackLogType.LookupStart, name, annotation, default))
        try:
            for dispatcher in self.current_path:
                result = await run_always_await_safely(
                    self.dispatcher_callable_detector(dispatcher), self
                )

                if result is None:
                    self.track_log.fluent_success = False
                    track_log.append((TrackLogType.Continue, name, dispatcher))
                    continue

                if result.__class__ is Force:
                    result = result.target

                track_log.append((TrackLogType.Result, name, dispatcher))
                self.execution_contexts[-1]._index = 0
                return result
            else:
                track_log.append((TrackLogType.RequirementCrashed, name))
                raise RequirementCrashed(
                    &#34;the dispatching requirement crashed: &#34;,
                    self.name,
                    self.annotation,
                    self.default,
                )
        finally:
            track_log.append((TrackLogType.LookupEnd, name))
            self.parameter_contexts.pop()

    async def lookup_using_current(self) -&gt; Any:
        result = None
        for dispatcher in self.current_path:
            result = await run_always_await_safely(
                self.dispatcher_callable_detector(dispatcher), self
            )
            if result is None:
                continue

            if result.__class__ is Force:
                result = result.target

            self.execution_contexts[-1]._index = 0
            return result
        else:
            raise RequirementCrashed(
                &#34;the dispatching requirement crashed: &#34;,
                self.name,
                self.annotation,
                self.default,
            )

    async def lookup_by_directly(
        self,
        dispatcher: T_Dispatcher,
        name: str,
        annotation: Any,
        default: Any,
        using_path: List[List[&#34;T_Dispatcher&#34;]] = None,
    ) -&gt; Any:
        self.parameter_contexts.append(
            ParameterContext(
                name, annotation, default, [], using_path or self.init_dispatch_path()
            )
        )

        dispatcher_callable = self.dispatcher_callable_detector(dispatcher)

        try:
            result = await run_always_await_safely(dispatcher_callable, self)
            if result.__class__ is Force:
                return result.target

            return result
        finally:
            self.parameter_contexts.pop()</code></pre>
</details>
<h3>Class variables</h3>
<dl>
<dt id="graia.broadcast.interfaces.dispatcher.DispatcherInterface.broadcast"><code class="name">var <span class="ident">broadcast</span> : Broadcast</code></dt>
<dd>
<div class="desc"></div>
</dd>
<dt id="graia.broadcast.interfaces.dispatcher.DispatcherInterface.execution_contexts"><code class="name">var <span class="ident">execution_contexts</span> : List[ExecutionContext]</code></dt>
<dd>
<div class="desc"></div>
</dd>
<dt id="graia.broadcast.interfaces.dispatcher.DispatcherInterface.parameter_contexts"><code class="name">var <span class="ident">parameter_contexts</span> : List[ParameterContext]</code></dt>
<dd>
<div class="desc"></div>
</dd>
<dt id="graia.broadcast.interfaces.dispatcher.DispatcherInterface.track_logs"><code class="name">var <span class="ident">track_logs</span> : List[<a title="graia.broadcast.entities.track_log.TrackLog" href="../entities/track_log.html#graia.broadcast.entities.track_log.TrackLog">TrackLog</a>]</code></dt>
<dd>
<div class="desc"></div>
</dd>
</dl>
<h3>Static methods</h3>
<dl>
<dt id="graia.broadcast.interfaces.dispatcher.DispatcherInterface.dispatcher_callable_detector"><code class="name flex">
<span>def <span class="ident">dispatcher_callable_detector</span></span>(<span>dispatcher: Union[Type[ForwardRef('BaseDispatcher')], ForwardRef('BaseDispatcher'), Callable[[ForwardRef('<a title="graia.broadcast.interfaces.dispatcher.DispatcherInterface" href="#graia.broadcast.interfaces.dispatcher.DispatcherInterface">DispatcherInterface</a>')], Any]]) ‑> Callable[[<a title="graia.broadcast.interfaces.dispatcher.DispatcherInterface" href="#graia.broadcast.interfaces.dispatcher.DispatcherInterface">DispatcherInterface</a>], Any]</span>
</code></dt>
<dd>
<div class="desc"></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">@staticmethod
@lru_cache(None)
def dispatcher_callable_detector(dispatcher: T_Dispatcher) -&gt; T_Dispatcher_Callable:
    if hasattr(dispatcher, &#34;catch&#34;):
        if isfunction(dispatcher.catch) or not isclass(dispatcher):
            return dispatcher.catch
        else:
            return partial(dispatcher.catch, None)
    elif callable(dispatcher):
        return dispatcher
    else:
        raise ValueError(&#34;invaild dispatcher: &#34;, dispatcher)</code></pre>
</details>
</dd>
<dt id="graia.broadcast.interfaces.dispatcher.DispatcherInterface.get_lifecycle_refs"><code class="name flex">
<span>def <span class="ident">get_lifecycle_refs</span></span>(<span>dispatcher: T_Dispatcher) ‑> Union[Dict[str, List], NoneType]</span>
</code></dt>
<dd>
<div class="desc"></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">@staticmethod
@lru_cache(None)
def get_lifecycle_refs(
    dispatcher: &#34;T_Dispatcher&#34;,
) -&gt; Optional[Dict[str, List]]:
    from graia.broadcast.entities.dispatcher import BaseDispatcher

    lifecycle_refs: Dict[str, List] = {}
    if not isinstance(dispatcher, (BaseDispatcher, type)):
        return

    for name in DEFAULT_LIFECYCLE_NAMES:
        lifecycle_refs.setdefault(name, [])
        abstract_lifecycle_func = cached_getattr(BaseDispatcher, name)
        unbound_attr = getattr(dispatcher, name, None)

        if unbound_attr is None:
            continue

        orig_call = unbound_attr
        while ismethod(orig_call):
            orig_call = unbound_attr.__func__

        if orig_call is abstract_lifecycle_func:
            continue

        lifecycle_refs[name].append(unbound_attr)

    return lifecycle_refs</code></pre>
</details>
</dd>
</dl>
<h3>Instance variables</h3>
<dl>
<dt id="graia.broadcast.interfaces.dispatcher.DispatcherInterface.annotation"><code class="name">var <span class="ident">annotation</span> : Any</code></dt>
<dd>
<div class="desc"></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">@property
def annotation(self) -&gt; Any:
    return self.parameter_contexts[-1].annotation</code></pre>
</details>
</dd>
<dt id="graia.broadcast.interfaces.dispatcher.DispatcherInterface.current_path"><code class="name">var <span class="ident">current_path</span> : <a title="graia.broadcast.utilles.NestableIterable" href="../utilles.html#graia.broadcast.utilles.NestableIterable">NestableIterable</a>[int, typing.Union[typing.Type[<a title="graia.broadcast.entities.dispatcher.BaseDispatcher" href="../entities/dispatcher.html#graia.broadcast.entities.dispatcher.BaseDispatcher">BaseDispatcher</a>], <a title="graia.broadcast.entities.dispatcher.BaseDispatcher" href="../entities/dispatcher.html#graia.broadcast.entities.dispatcher.BaseDispatcher">BaseDispatcher</a>, typing.Callable[[<a title="graia.broadcast.interfaces.dispatcher.DispatcherInterface" href="#graia.broadcast.interfaces.dispatcher.DispatcherInterface">DispatcherInterface</a>], typing.Any]]]</code></dt>
<dd>
<div class="desc"></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">@property
def current_path(self) -&gt; NestableIterable[int, T_Dispatcher]:
    return self.parameter_contexts[-1].path</code></pre>
</details>
</dd>
<dt id="graia.broadcast.interfaces.dispatcher.DispatcherInterface.default"><code class="name">var <span class="ident">default</span> : Any</code></dt>
<dd>
<div class="desc"></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">@property
def default(self) -&gt; Any:
    return self.parameter_contexts[-1].default</code></pre>
</details>
</dd>
<dt id="graia.broadcast.interfaces.dispatcher.DispatcherInterface.event"><code class="name">var <span class="ident">event</span> : <a title="graia.broadcast.entities.event.BaseEvent" href="../entities/event.html#graia.broadcast.entities.event.BaseEvent">BaseEvent</a></code></dt>
<dd>
<div class="desc"></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">@property
def event(self) -&gt; BaseEvent:
    return self.execution_contexts[-1].event</code></pre>
</details>
</dd>
<dt id="graia.broadcast.interfaces.dispatcher.DispatcherInterface.global_dispatcher"><code class="name">var <span class="ident">global_dispatcher</span> : List[Union[Type[<a title="graia.broadcast.entities.dispatcher.BaseDispatcher" href="../entities/dispatcher.html#graia.broadcast.entities.dispatcher.BaseDispatcher">BaseDispatcher</a>], <a title="graia.broadcast.entities.dispatcher.BaseDispatcher" href="../entities/dispatcher.html#graia.broadcast.entities.dispatcher.BaseDispatcher">BaseDispatcher</a>, Callable[[<a title="graia.broadcast.interfaces.dispatcher.DispatcherInterface" href="#graia.broadcast.interfaces.dispatcher.DispatcherInterface">DispatcherInterface</a>], Any]]]</code></dt>
<dd>
<div class="desc"></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">@property
def global_dispatcher(self) -&gt; List[T_Dispatcher]:
    return self.execution_contexts[0].dispatchers</code></pre>
</details>
</dd>
<dt id="graia.broadcast.interfaces.dispatcher.DispatcherInterface.has_current_exec_context"><code class="name">var <span class="ident">has_current_exec_context</span> : bool</code></dt>
<dd>
<div class="desc"></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">@property
def has_current_exec_context(self) -&gt; bool:
    return len(self.execution_contexts) &gt;= 2</code></pre>
</details>
</dd>
<dt id="graia.broadcast.interfaces.dispatcher.DispatcherInterface.has_current_param_context"><code class="name">var <span class="ident">has_current_param_context</span> : bool</code></dt>
<dd>
<div class="desc"></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">@property
def has_current_param_context(self) -&gt; bool:
    return len(self.parameter_contexts) &gt;= 2</code></pre>
</details>
</dd>
<dt id="graia.broadcast.interfaces.dispatcher.DispatcherInterface.name"><code class="name">var <span class="ident">name</span> : str</code></dt>
<dd>
<div class="desc"></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">@property
def name(self) -&gt; str:
    return self.parameter_contexts[-1].name</code></pre>
</details>
</dd>
<dt id="graia.broadcast.interfaces.dispatcher.DispatcherInterface.track_log"><code class="name">var <span class="ident">track_log</span></code></dt>
<dd>
<div class="desc"></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">@property
def track_log(self):
    return self.track_logs[-1]</code></pre>
</details>
</dd>
</dl>
<h3>Methods</h3>
<dl>
<dt id="graia.broadcast.interfaces.dispatcher.DispatcherInterface.dispatcher_pure_generator"><code class="name flex">
<span>def <span class="ident">dispatcher_pure_generator</span></span>(<span>self) ‑> Generator[NoneType, NoneType, Union[Type[<a title="graia.broadcast.entities.dispatcher.BaseDispatcher" href="../entities/dispatcher.html#graia.broadcast.entities.dispatcher.BaseDispatcher">BaseDispatcher</a>], <a title="graia.broadcast.entities.dispatcher.BaseDispatcher" href="../entities/dispatcher.html#graia.broadcast.entities.dispatcher.BaseDispatcher">BaseDispatcher</a>, Callable[[<a title="graia.broadcast.interfaces.dispatcher.DispatcherInterface" href="#graia.broadcast.interfaces.dispatcher.DispatcherInterface">DispatcherInterface</a>], Any]]]</span>
</code></dt>
<dd>
<div class="desc"></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def dispatcher_pure_generator(self) -&gt; Generator[None, None, T_Dispatcher]:
    return itertools.chain(
        self.execution_contexts[0].dispatchers,
        self.parameter_contexts[-1].dispatchers,
        self.execution_contexts[-1].dispatchers,
    )</code></pre>
</details>
</dd>
<dt id="graia.broadcast.interfaces.dispatcher.DispatcherInterface.exec_lifecycle"><code class="name flex">
<span>async def <span class="ident">exec_lifecycle</span></span>(<span>self, lifecycle_name: str, *args, **kwargs)</span>
</code></dt>
<dd>
<div class="desc"></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">async def exec_lifecycle(self, lifecycle_name: str, *args, **kwargs):
    lifecycle_funcs = self.execution_contexts[-1].lifecycle_refs.get(
        lifecycle_name, []
    )
    if lifecycle_funcs:
        for func in lifecycle_funcs:
            await run_always_await_safely(func, self, *args, **kwargs)</code></pre>
</details>
</dd>
<dt id="graia.broadcast.interfaces.dispatcher.DispatcherInterface.exit_current_execution"><code class="name flex">
<span>async def <span class="ident">exit_current_execution</span></span>(<span>self)</span>
</code></dt>
<dd>
<div class="desc"></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">async def exit_current_execution(self):
    self.execution_contexts.pop()
    self.track_logs.pop()</code></pre>
</details>
</dd>
<dt id="graia.broadcast.interfaces.dispatcher.DispatcherInterface.flush_lifecycle_refs"><code class="name flex">
<span>def <span class="ident">flush_lifecycle_refs</span></span>(<span>self, dispatchers: List[ForwardRef('T_Dispatcher')] = None)</span>
</code></dt>
<dd>
<div class="desc"></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def flush_lifecycle_refs(
    self,
    dispatchers: List[&#34;T_Dispatcher&#34;] = None,
):
    from graia.broadcast.entities.dispatcher import BaseDispatcher

    lifecycle_refs = self.execution_contexts[-1].lifecycle_refs
    if dispatchers is None and lifecycle_refs:  # 已经刷新.
        return

    for dispatcher in dispatchers or self.dispatcher_pure_generator():
        if (
            not isinstance(dispatcher, BaseDispatcher)
            or dispatcher.__class__ is type
        ):
            continue

        for name, value in self.get_lifecycle_refs(dispatcher).items():
            lifecycle_refs.setdefault(name, [])
            lifecycle_refs[name].extend(value)</code></pre>
</details>
</dd>
<dt id="graia.broadcast.interfaces.dispatcher.DispatcherInterface.init_dispatch_path"><code class="name flex">
<span>def <span class="ident">init_dispatch_path</span></span>(<span>self) ‑> List[List[Union[Type[BaseDispatcher], BaseDispatcher, Callable[[<a title="graia.broadcast.interfaces.dispatcher.DispatcherInterface" href="#graia.broadcast.interfaces.dispatcher.DispatcherInterface">DispatcherInterface</a>], Any]]]]</span>
</code></dt>
<dd>
<div class="desc"></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def init_dispatch_path(self) -&gt; List[List[&#34;T_Dispatcher&#34;]]:
    return [
        [],
        self.execution_contexts[0].dispatchers,
        self.parameter_contexts[-1].dispatchers,
        self.execution_contexts[-1].dispatchers,
    ]</code></pre>
</details>
</dd>
<dt id="graia.broadcast.interfaces.dispatcher.DispatcherInterface.inject_execution_raw"><code class="name flex">
<span>def <span class="ident">inject_execution_raw</span></span>(<span>self, *dispatchers: List[ForwardRef('T_Dispatcher')])</span>
</code></dt>
<dd>
<div class="desc"></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def inject_execution_raw(self, *dispatchers: List[&#34;T_Dispatcher&#34;]):
    for dispatcher in dispatchers:
        self.execution_contexts[-1].dispatchers.insert(0, dispatcher)

    self.flush_lifecycle_refs(dispatchers)</code></pre>
</details>
</dd>
<dt id="graia.broadcast.interfaces.dispatcher.DispatcherInterface.inject_global_raw"><code class="name flex">
<span>def <span class="ident">inject_global_raw</span></span>(<span>self, *dispatchers: List[ForwardRef('T_Dispatcher')])</span>
</code></dt>
<dd>
<div class="desc"></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def inject_global_raw(self, *dispatchers: List[&#34;T_Dispatcher&#34;]):
    # self.dispatchers.extend(dispatchers)
    for dispatcher in dispatchers[::-1]:
        self.execution_contexts[0].dispatchers.insert(1, dispatcher)

    self.flush_lifecycle_refs(dispatchers)</code></pre>
</details>
</dd>
<dt id="graia.broadcast.interfaces.dispatcher.DispatcherInterface.inject_local_raw"><code class="name flex">
<span>def <span class="ident">inject_local_raw</span></span>(<span>self, *dispatchers: List[ForwardRef('T_Dispatcher')])</span>
</code></dt>
<dd>
<div class="desc"></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def inject_local_raw(self, *dispatchers: List[&#34;T_Dispatcher&#34;]):
    # 为什么没有 flush: 因为这里的 lifecycle 是无意义的.
    for dispatcher in dispatchers[::-1]:
        self.parameter_contexts[-1].dispatchers.insert(0, dispatcher)</code></pre>
</details>
</dd>
<dt id="graia.broadcast.interfaces.dispatcher.DispatcherInterface.lookup_by_directly"><code class="name flex">
<span>async def <span class="ident">lookup_by_directly</span></span>(<span>self, dispatcher: Union[Type[ForwardRef('BaseDispatcher')], ForwardRef('BaseDispatcher'), Callable[[ForwardRef('<a title="graia.broadcast.interfaces.dispatcher.DispatcherInterface" href="#graia.broadcast.interfaces.dispatcher.DispatcherInterface">DispatcherInterface</a>')], Any]], name: str, annotation: Any, default: Any, using_path: List[List[ForwardRef('T_Dispatcher')]] = None) ‑> Any</span>
</code></dt>
<dd>
<div class="desc"></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">async def lookup_by_directly(
    self,
    dispatcher: T_Dispatcher,
    name: str,
    annotation: Any,
    default: Any,
    using_path: List[List[&#34;T_Dispatcher&#34;]] = None,
) -&gt; Any:
    self.parameter_contexts.append(
        ParameterContext(
            name, annotation, default, [], using_path or self.init_dispatch_path()
        )
    )

    dispatcher_callable = self.dispatcher_callable_detector(dispatcher)

    try:
        result = await run_always_await_safely(dispatcher_callable, self)
        if result.__class__ is Force:
            return result.target

        return result
    finally:
        self.parameter_contexts.pop()</code></pre>
</details>
</dd>
<dt id="graia.broadcast.interfaces.dispatcher.DispatcherInterface.lookup_param"><code class="name flex">
<span>async def <span class="ident">lookup_param</span></span>(<span>self, name: str, annotation: Any, default: Any, using_path: List[List[ForwardRef('T_Dispatcher')]] = None) ‑> Any</span>
</code></dt>
<dd>
<div class="desc"></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">async def lookup_param(
    self,
    name: str,
    annotation: Any,
    default: Any,
    using_path: List[List[&#34;T_Dispatcher&#34;]] = None,
) -&gt; Any:
    self.parameter_contexts.append(
        ParameterContext(
            name, annotation, default, [], using_path or self.init_dispatch_path()
        )
    )
    track_log = self.track_log.log

    track_log.append((TrackLogType.LookupStart, name, annotation, default))
    try:
        for dispatcher in self.current_path:
            result = await run_always_await_safely(
                self.dispatcher_callable_detector(dispatcher), self
            )

            if result is None:
                self.track_log.fluent_success = False
                track_log.append((TrackLogType.Continue, name, dispatcher))
                continue

            if result.__class__ is Force:
                result = result.target

            track_log.append((TrackLogType.Result, name, dispatcher))
            self.execution_contexts[-1]._index = 0
            return result
        else:
            track_log.append((TrackLogType.RequirementCrashed, name))
            raise RequirementCrashed(
                &#34;the dispatching requirement crashed: &#34;,
                self.name,
                self.annotation,
                self.default,
            )
    finally:
        track_log.append((TrackLogType.LookupEnd, name))
        self.parameter_contexts.pop()</code></pre>
</details>
</dd>
<dt id="graia.broadcast.interfaces.dispatcher.DispatcherInterface.lookup_param_without_log"><code class="name flex">
<span>async def <span class="ident">lookup_param_without_log</span></span>(<span>self, name: str, annotation: Any, default: Any, using_path: List[List[ForwardRef('T_Dispatcher')]] = None) ‑> Any</span>
</code></dt>
<dd>
<div class="desc"></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">async def lookup_param_without_log(
    self,
    name: str,
    annotation: Any,
    default: Any,
    using_path: List[List[&#34;T_Dispatcher&#34;]] = None,
) -&gt; Any:
    self.parameter_contexts.append(
        ParameterContext(
            name, annotation, default, [], using_path or self.init_dispatch_path()
        )
    )

    result = None
    try:
        for dispatcher in self.current_path:
            result = await run_always_await_safely(
                self.dispatcher_callable_detector(dispatcher), self
            )

            if result is None:
                continue

            if result.__class__ is Force:
                result = result.target

            self.execution_contexts[-1]._index = 0
            return result
        else:
            raise RequirementCrashed(
                &#34;the dispatching requirement crashed: &#34;,
                self.name,
                self.annotation,
                self.default,
            )
    finally:
        self.parameter_contexts.pop()</code></pre>
</details>
</dd>
<dt id="graia.broadcast.interfaces.dispatcher.DispatcherInterface.lookup_using_current"><code class="name flex">
<span>async def <span class="ident">lookup_using_current</span></span>(<span>self) ‑> Any</span>
</code></dt>
<dd>
<div class="desc"></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">async def lookup_using_current(self) -&gt; Any:
    result = None
    for dispatcher in self.current_path:
        result = await run_always_await_safely(
            self.dispatcher_callable_detector(dispatcher), self
        )
        if result is None:
            continue

        if result.__class__ is Force:
            result = result.target

        self.execution_contexts[-1]._index = 0
        return result
    else:
        raise RequirementCrashed(
            &#34;the dispatching requirement crashed: &#34;,
            self.name,
            self.annotation,
            self.default,
        )</code></pre>
</details>
</dd>
<dt id="graia.broadcast.interfaces.dispatcher.DispatcherInterface.start_execution"><code class="name flex">
<span>def <span class="ident">start_execution</span></span>(<span>self, event: <a title="graia.broadcast.entities.event.BaseEvent" href="../entities/event.html#graia.broadcast.entities.event.BaseEvent">BaseEvent</a>, dispatchers: List[Union[Type[ForwardRef('BaseDispatcher')], ForwardRef('BaseDispatcher'), Callable[[ForwardRef('<a title="graia.broadcast.interfaces.dispatcher.DispatcherInterface" href="#graia.broadcast.interfaces.dispatcher.DispatcherInterface">DispatcherInterface</a>')], Any]]], track_log_receiver: <a title="graia.broadcast.entities.track_log.TrackLog" href="../entities/track_log.html#graia.broadcast.entities.track_log.TrackLog">TrackLog</a> = None) ‑> <a title="graia.broadcast.interfaces.dispatcher.DispatcherInterface" href="#graia.broadcast.interfaces.dispatcher.DispatcherInterface">DispatcherInterface</a></span>
</code></dt>
<dd>
<div class="desc"></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def start_execution(
    self,
    event: BaseEvent,
    dispatchers: List[T_Dispatcher],
    track_log_receiver: TrackLog = None,
) -&gt; &#34;DispatcherInterface&#34;:
    self.execution_contexts.append(ExecutionContext(dispatchers, event))
    self.flush_lifecycle_refs()
    self.track_logs.append(track_log_receiver or TrackLog())
    return self</code></pre>
</details>
</dd>
</dl>
</dd>
<dt id="graia.broadcast.interfaces.dispatcher.EmptyEvent"><code class="flex name class">
<span>class <span class="ident">EmptyEvent</span></span>
<span>(</span><span>**data: Any)</span>
</code></dt>
<dd>
<div class="desc"><p>Create a new model by parsing and validating input data from keyword arguments.</p>
<p>Raises ValidationError if the input data cannot be parsed to form a valid model.</p></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">class EmptyEvent(BaseEvent):
    class Dispatcher(BaseDispatcher):
        @staticmethod
        def catch(_):
            pass</code></pre>
</details>
<h3>Ancestors</h3>
<ul class="hlist">
<li><a title="graia.broadcast.entities.event.BaseEvent" href="../entities/event.html#graia.broadcast.entities.event.BaseEvent">BaseEvent</a></li>
<li>pydantic.main.BaseModel</li>
<li>pydantic.utils.Representation</li>
</ul>
<h3>Class variables</h3>
<dl>
<dt id="graia.broadcast.interfaces.dispatcher.EmptyEvent.Dispatcher"><code class="name">var <span class="ident">Dispatcher</span></code></dt>
<dd>
<div class="desc"><p>所有非单函数型 Dispatcher 的基类, 用于为参数解析提供可扩展的支持.</p></div>
</dd>
</dl>
</dd>
</dl>
</section>
</article>
<nav id="sidebar">
<h1>Index</h1>
<div class="toc">
<ul></ul>
</div>
<ul id="index">
<li><h3>Super-module</h3>
<ul>
<li><code><a title="graia.broadcast.interfaces" href="index.html">graia.broadcast.interfaces</a></code></li>
</ul>
</li>
<li><h3><a href="#header-classes">Classes</a></h3>
<ul>
<li>
<h4><code><a title="graia.broadcast.interfaces.dispatcher.DispatcherInterface" href="#graia.broadcast.interfaces.dispatcher.DispatcherInterface">DispatcherInterface</a></code></h4>
<ul class="">
<li><code><a title="graia.broadcast.interfaces.dispatcher.DispatcherInterface.annotation" href="#graia.broadcast.interfaces.dispatcher.DispatcherInterface.annotation">annotation</a></code></li>
<li><code><a title="graia.broadcast.interfaces.dispatcher.DispatcherInterface.broadcast" href="#graia.broadcast.interfaces.dispatcher.DispatcherInterface.broadcast">broadcast</a></code></li>
<li><code><a title="graia.broadcast.interfaces.dispatcher.DispatcherInterface.current_path" href="#graia.broadcast.interfaces.dispatcher.DispatcherInterface.current_path">current_path</a></code></li>
<li><code><a title="graia.broadcast.interfaces.dispatcher.DispatcherInterface.default" href="#graia.broadcast.interfaces.dispatcher.DispatcherInterface.default">default</a></code></li>
<li><code><a title="graia.broadcast.interfaces.dispatcher.DispatcherInterface.dispatcher_callable_detector" href="#graia.broadcast.interfaces.dispatcher.DispatcherInterface.dispatcher_callable_detector">dispatcher_callable_detector</a></code></li>
<li><code><a title="graia.broadcast.interfaces.dispatcher.DispatcherInterface.dispatcher_pure_generator" href="#graia.broadcast.interfaces.dispatcher.DispatcherInterface.dispatcher_pure_generator">dispatcher_pure_generator</a></code></li>
<li><code><a title="graia.broadcast.interfaces.dispatcher.DispatcherInterface.event" href="#graia.broadcast.interfaces.dispatcher.DispatcherInterface.event">event</a></code></li>
<li><code><a title="graia.broadcast.interfaces.dispatcher.DispatcherInterface.exec_lifecycle" href="#graia.broadcast.interfaces.dispatcher.DispatcherInterface.exec_lifecycle">exec_lifecycle</a></code></li>
<li><code><a title="graia.broadcast.interfaces.dispatcher.DispatcherInterface.execution_contexts" href="#graia.broadcast.interfaces.dispatcher.DispatcherInterface.execution_contexts">execution_contexts</a></code></li>
<li><code><a title="graia.broadcast.interfaces.dispatcher.DispatcherInterface.exit_current_execution" href="#graia.broadcast.interfaces.dispatcher.DispatcherInterface.exit_current_execution">exit_current_execution</a></code></li>
<li><code><a title="graia.broadcast.interfaces.dispatcher.DispatcherInterface.flush_lifecycle_refs" href="#graia.broadcast.interfaces.dispatcher.DispatcherInterface.flush_lifecycle_refs">flush_lifecycle_refs</a></code></li>
<li><code><a title="graia.broadcast.interfaces.dispatcher.DispatcherInterface.get_lifecycle_refs" href="#graia.broadcast.interfaces.dispatcher.DispatcherInterface.get_lifecycle_refs">get_lifecycle_refs</a></code></li>
<li><code><a title="graia.broadcast.interfaces.dispatcher.DispatcherInterface.global_dispatcher" href="#graia.broadcast.interfaces.dispatcher.DispatcherInterface.global_dispatcher">global_dispatcher</a></code></li>
<li><code><a title="graia.broadcast.interfaces.dispatcher.DispatcherInterface.has_current_exec_context" href="#graia.broadcast.interfaces.dispatcher.DispatcherInterface.has_current_exec_context">has_current_exec_context</a></code></li>
<li><code><a title="graia.broadcast.interfaces.dispatcher.DispatcherInterface.has_current_param_context" href="#graia.broadcast.interfaces.dispatcher.DispatcherInterface.has_current_param_context">has_current_param_context</a></code></li>
<li><code><a title="graia.broadcast.interfaces.dispatcher.DispatcherInterface.init_dispatch_path" href="#graia.broadcast.interfaces.dispatcher.DispatcherInterface.init_dispatch_path">init_dispatch_path</a></code></li>
<li><code><a title="graia.broadcast.interfaces.dispatcher.DispatcherInterface.inject_execution_raw" href="#graia.broadcast.interfaces.dispatcher.DispatcherInterface.inject_execution_raw">inject_execution_raw</a></code></li>
<li><code><a title="graia.broadcast.interfaces.dispatcher.DispatcherInterface.inject_global_raw" href="#graia.broadcast.interfaces.dispatcher.DispatcherInterface.inject_global_raw">inject_global_raw</a></code></li>
<li><code><a title="graia.broadcast.interfaces.dispatcher.DispatcherInterface.inject_local_raw" href="#graia.broadcast.interfaces.dispatcher.DispatcherInterface.inject_local_raw">inject_local_raw</a></code></li>
<li><code><a title="graia.broadcast.interfaces.dispatcher.DispatcherInterface.lookup_by_directly" href="#graia.broadcast.interfaces.dispatcher.DispatcherInterface.lookup_by_directly">lookup_by_directly</a></code></li>
<li><code><a title="graia.broadcast.interfaces.dispatcher.DispatcherInterface.lookup_param" href="#graia.broadcast.interfaces.dispatcher.DispatcherInterface.lookup_param">lookup_param</a></code></li>
<li><code><a title="graia.broadcast.interfaces.dispatcher.DispatcherInterface.lookup_param_without_log" href="#graia.broadcast.interfaces.dispatcher.DispatcherInterface.lookup_param_without_log">lookup_param_without_log</a></code></li>
<li><code><a title="graia.broadcast.interfaces.dispatcher.DispatcherInterface.lookup_using_current" href="#graia.broadcast.interfaces.dispatcher.DispatcherInterface.lookup_using_current">lookup_using_current</a></code></li>
<li><code><a title="graia.broadcast.interfaces.dispatcher.DispatcherInterface.name" href="#graia.broadcast.interfaces.dispatcher.DispatcherInterface.name">name</a></code></li>
<li><code><a title="graia.broadcast.interfaces.dispatcher.DispatcherInterface.parameter_contexts" href="#graia.broadcast.interfaces.dispatcher.DispatcherInterface.parameter_contexts">parameter_contexts</a></code></li>
<li><code><a title="graia.broadcast.interfaces.dispatcher.DispatcherInterface.start_execution" href="#graia.broadcast.interfaces.dispatcher.DispatcherInterface.start_execution">start_execution</a></code></li>
<li><code><a title="graia.broadcast.interfaces.dispatcher.DispatcherInterface.track_log" href="#graia.broadcast.interfaces.dispatcher.DispatcherInterface.track_log">track_log</a></code></li>
<li><code><a title="graia.broadcast.interfaces.dispatcher.DispatcherInterface.track_logs" href="#graia.broadcast.interfaces.dispatcher.DispatcherInterface.track_logs">track_logs</a></code></li>
</ul>
</li>
<li>
<h4><code><a title="graia.broadcast.interfaces.dispatcher.EmptyEvent" href="#graia.broadcast.interfaces.dispatcher.EmptyEvent">EmptyEvent</a></code></h4>
<ul class="">
<li><code><a title="graia.broadcast.interfaces.dispatcher.EmptyEvent.Dispatcher" href="#graia.broadcast.interfaces.dispatcher.EmptyEvent.Dispatcher">Dispatcher</a></code></li>
</ul>
</li>
</ul>
</li>
</ul>
</nav>
</main>
<footer id="footer">
<p>Generated by <a href="https://pdoc3.github.io/pdoc"><cite>pdoc</cite> 0.9.2</a>.</p>
</footer>
</body>
</html>